var express = require('express');
var router = express.Router();
var sqlite3 = require('sqlite3').verbose();
var path = require('path');
/* GET users listing. */
router.get('/', function(req, res, next) {
    // if(req.query.test_login== "1"){
    //     if(req.session.username == undefined || req.session.username == "")
    //         res.send('0');
    // }
    // else{
        var db=new sqlite3.Database(path.join(__dirname, "../db/LH.s3db"));
        try{
            sqlStr1="UPDATE activity SET a_name=?,s_time=?,e_time=?,intro=?,status=?,rule=?,lh_rule=?,type=?,link=? where a_no=?";
            var no =req.query.ano;
                    var collegeno=no.substring(0,2);
                    var name = req.query.actname;
                    var start_ = req.query.actstart;
                    var end_ = req.query.actend;
                    var intro_ = req.query.actintro;
                    var status_=0;
                    var snum=0;//小傻瓜刚开始肯定为0哇
                    var rule = req.query.actrequire;
                    var lhrule = req.query.actbonus;
                    var type_ = req.query.actype;
                    var img=req.query.actimg;//http://balabala;
                    db.all(sqlStr1,[name,start_,end_,intro_,0,rule,lhrule,type_,img,no],function(err){
                        if(err==null){
                            res.send("1");
                        }else{
                            res.send("0");
                        }
                    });
            
           
        }catch(ex){
            console.log(ex);
        };
    // }
});
module.exports = router;
